package com.qq.service.impl;

import com.qq.dao.SysUserDao;
import com.qq.pojo.SysUser;
import com.qq.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class SysUserServiceImpl implements SysUserService {
    @Autowired(required = false)
    private SysUserDao sysUserDao;


    /**
     * 注册
     * @param user
     * @return
     */
    @Override
    public int insertUser(SysUser user) {
        return  sysUserDao.insertUser(user);

    }

    /**
     * 通过电话，密码查询用户
     * @param tel
     * @param password
     * @return
     */
    @Override
    public SysUser findUser(String tel, String password) {
        return sysUserDao.findUser(tel,password);
    }

    /**
     * 通过电话查询用户
     * @param tel
     * @return
     */
    @Override
    public SysUser findByTel(String tel) {
        SysUser byTel = sysUserDao.findByTel(tel);
        return byTel;
    }

    /**
     * 通过邀请码查询用户
     * @param invitation
     * @return
     */
    @Override
    public SysUser findByinvitation(String invitation) {
        SysUser byinvitation = sysUserDao.findByinvitation(invitation);
        return byinvitation;
    }

    /**
     * 根据id查找
     * @param id
     * @return
     */
    @Override
    public SysUser findById(int id) {
        return sysUserDao.findUserById(id);
    }

    /**
     * 动态SQL修改
     * @param tel
     * @param id
     */
    @Override
    public void bigUpdate(String tel, int id) {
        SysUser user = new SysUser();
        user.setId(id);
        user.setTel(tel);
        sysUserDao.bigUpdate(user);
    }

    /**
     * 邮箱查询
     * @param email
     * @return
     */
    @Override
    public SysUser findUserEmail(String email) {
        return sysUserDao.findUserEmail(email);
    }

    @Override
    public void updatePasswordById(String password, int id) {
        SysUser user = new SysUser();
        user.setId(id);
        user.setPassword(password);
        sysUserDao.updatePasswordById(user);
    }
}
